home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / prolog / sbprolog / amiga / c_src2_5.zoo / print_inst.c < prev    next >
C/C++ Source or Header  |  1988-08-07  |  3KB  |  133 lines

  1. /************************************************************************
  2. *                                    *
  3. * The SB-Prolog System                            *
  4. * Copyright SUNY at Stony Brook, 1986; University of Arizona, 1987    *
  5. *                                    *
  6. ************************************************************************/
  7.  
  8. /*-----------------------------------------------------------------
  9. SB-Prolog is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY.  No author or distributor
  11. accepts responsibility to anyone for the consequences of using it
  12. or for whether it serves any particular purpose or works at all,
  13. unless he says so in writing.  Refer to the SB-Prolog General Public
  14. License for full details.
  15.  
  16. Everyone is granted permission to copy, modify and redistribute
  17. SB-Prolog, but only under the conditions described in the
  18. SB-Prolog General Public License.   A copy of this license is
  19. supposed to have been given to you along with SB-Prolog so you
  20. can know your rights and responsibilities.  It should be in a
  21. file named COPYING.  Among other things, the copyright notice
  22. and this notice must be preserved on all copies. 
  23. ------------------------------------------------------------------ */
  24.  
  25. #include "inst.h"
  26. #include "sim.h"
  27.  
  28.  
  29. #define printop1(tp) \
  30.           fprintf(fd, "\t %x",(tp)oprnd1) ; fflush(stdout)
  31. #define printop2(tp) \
  32.           fprintf(fd, "\t %x",(tp)oprnd2) ; fflush(stdout)
  33. #define printop3(tp) \
  34.           fprintf(fd, "\t %x",(tp)oprnd3) ; fflush(stdout)
  35.  
  36. print_inst(fd, inst_ptr)
  37. FILE *fd;
  38. byte *inst_ptr;
  39. {
  40.     byte *lpcreg; /* local pc register for macros to use */
  41.     byte opcode; int i;
  42.     lpcreg = inst_ptr;
  43.     if (num_line) fprintf(fd,"%x\t",lpcreg);
  44.     opcode = *lpcreg++;
  45.     fprintf(fd, inst_name[opcode]);
  46.     switch (parse_table[opcode]) {
  47.  
  48.     case E: break;
  49.  
  50.     case PBB: parse_opPBB;
  51.         printop1(byte);
  52.         printop2(byte);
  53.         break;
  54.  
  55.     case BBB: parse_opBBB;
  56.         printop1(byte);
  57.         printop2(byte);
  58.         printop3(byte);
  59.         break;
  60.         
  61.     case BC:
  62.     case BW: parse_opBW;
  63.             printop1(byte);
  64.             printop2(word);
  65.         break;
  66.  
  67.     case B: parse_opB;
  68.         printop1(byte);
  69.         if (opcode == hash) {
  70.            fprintf(fd, "\n");
  71.            for (i = 0; i < oprnd1; i++) {
  72.             if (num_line) fprintf(fd, "%x\t", lpcreg);
  73.             fprintf(fd, "\t %x\n", *((pw)lpcreg));
  74.             lpcreg += 4;
  75.            }
  76.         }
  77.         break;
  78.  
  79.     case PC:
  80.     case PW: parse_opPW;
  81.         printop1(word);
  82.         break;
  83.  
  84.     case PL: parse_opPL;
  85.         printop1(long);
  86.         break;
  87.  
  88.     case BA: parse_opBA;
  89.         printop1(byte);
  90.         printop2(word);
  91.         break;
  92.  
  93.     case BAA: parse_opBAA;
  94.         printop1(byte);
  95.         printop2(word);
  96.         printop3(word);
  97.              if (opcode == switchonbound) { /* I don't understand this
  98.                 code, didn't write it,  and refuse to be
  99.                 responsible for it.  It doesn't seem to work
  100.                 right anyway.  --SKD */
  101.            fprintf(fd, "\n");
  102.            if (num_line) fprintf(fd, "%x\t", lpcreg);
  103.            opcode = *lpcreg++;
  104.            fprintf(fd, inst_name[opcode]);
  105.            parse_opPA;
  106.            printop1(word); fprintf(fd, "\n");
  107.            for (i = 0; i < oprnd3; i++) {
  108.              if (num_line) fprintf(fd, "%x\t", lpcreg);
  109.              fprintf(fd, "\t %x\n", *((pw)lpcreg));
  110.              lpcreg += 4;
  111.            }
  112.         }
  113.         break;
  114.  
  115.     case PA: parse_opPA;
  116.         printop1(word);
  117.         break;
  118.  
  119.     case BL: parse_opBL;
  120.         printop1(byte);
  121.         printop2(long);
  122.         break;
  123.  
  124.     case P: parse_opP;
  125.         if (opcode == noop) lpcreg += 2 * oprnd1;
  126.         break;
  127.     }  /* end switch */
  128.     pcreg = lpcreg;
  129.     fprintf(fd, "\n");
  130. } /* print_inst */
  131.  
  132.  
  133.